{include file="header.html"}
<style>
.some-star{ color:#f00; font-weight:700;}
.form-group{ margin-bottom:5px; }
input[type="text"]{ padding:4px; }
.form-inline select:not([multiple]), .form-group select:not([multiple]){ height:31px; }
.form-group textarea{ height:50px; }
</style>
<div class="page-header">
	<h6>
		汇总管理
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			编辑记录
		</small>
	</h6>
</div>
<div class="row">
<div class="col-xs-12">
	<form class="form-horizontal" role="form" method="post" action="?app=collect&act=edit" enctype="multipart/form-data" onsubmit="return check()">
		<input type="hidden" name="id" value="{$row->id}" />
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="city_id"> <span class="some-star">*</span> 城市 </label>
			<div class="col-sm-2">
				<select id="city_id" name="city_id">
				<option value="">请选择</option>
				{foreach from=$city item=g}
				<option value="{$g->city_id}" {if $g->city_id==$row->city_id}selected{/if}>{$g->city_name}</option>
				{/foreach}
				</select>
				<span class="some-line"></span>
				<select id="casy_id" name="casy_id">
				<option value="">请选择社保档次</option>
				</select>
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="member_type"> <span class="some-star">*</span> 付款渠道 </label>
			<div class="col-sm-4">
				<select id="member_type" name="member_type">
				<option value="">请选择</option>
				<option value="本站" {if $row->member_type=='本站'}selected{/if}>本站</option>
				<option value="淘宝欢创总店" {if $row->member_type=='淘宝欢创总店'}selected{/if}>淘宝欢创总店</option>
				<option value="天猫总店" {if $row->member_type=='天猫总店'}selected{/if}>天猫总店</option>
				<option value="淘宝广州社保代缴店" {if $row->member_type=='淘宝广州社保代缴店'}selected{/if}>淘宝广州社保代缴店</option>
				<option value="转到公账" {if $row->member_type=='转到公账'}selected{/if}>转到公账</option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="member_name"> <span class="some-star">*</span> 账号 </label>
			<div class="col-sm-2">
				<input type="text" id="member_name" name="member_name" value="{$row->member_name}" class="col-xs-12" />
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="begin_time"> <span class="some-star">*</span> 首次缴费日期 </label>
			<div class="col-sm-2">
				<input type="text" id="begin_time" name="begin_time" value="{if $row->begin_time>0}{date('Y-m-d', $row->begin_time)}{/if}" class="col-xs-12" />
			</div>
		</div>
		<div class="form-group">
			<!--<label class="col-sm-2 control-label no-padding-right" for="end_time"> 到期日期 </label>
			<div class="col-sm-4">
				<input type="text" id="end_time" name="end_time" value="{if $row->end_time>0}{date('Y-m-d', $row->end_time)}{/if}" class="col-xs-6" />
			</div>-->
			<label class="col-sm-2 control-label no-padding-right" for="real_name"> <span class="some-star">*</span> 姓名 </label>
			<div class="col-sm-2">
				<input type="text" id="real_name" name="real_name" value="{$row->real_name}" class="col-xs-12" />
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="idcard"> <span class="some-star">*</span> 身份证 </label>
			<div class="col-sm-2">
				<input type="text" id="idcard" name="idcard" value="{$row->idcard}" class="col-xs-12" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="social_number"> 社保号 </label>
			<div class="col-sm-2">
				<input type="text" id="social_number" name="social_number" value="{$row->social_number}" class="col-xs-12" />
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="gjj_number"> 公积金账号 </label>
			<div class="col-sm-2">
				<input type="text" id="gjj_number" name="gjj_number" value="{$row->gjj_number}" class="col-xs-12" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="person_type"> 户口性质 </label>
			<div class="col-sm-2">
				<select id="person_type" name="person_type">
				<option value="本地城镇" {if $row->person_type=='本地城镇'}selected{/if}>本地城镇</option>
				<option value="本地农村" {if $row->person_type=='本地农村'}selected{/if}>本地农村</option>
				<option value="外地城镇" {if $row->person_type=='外地城镇'}selected{/if}>外地城镇</option>
				<option value="外地农村" {if $row->person_type=='外地农村'}selected{/if}>外地农村</option>
				</select>
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="mobile"> 联系电话 </label>
			<div class="col-sm-2">
				<input type="text" id="mobile" name="mobile" value="{$row->mobile}" class="col-xs-12" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="month"> <span class="some-star">*</span> 社保缴费月份 </label>
			<div class="col-sm-2">
				<input type="text" id="begin_month" name="begin_month" @="#end_month" value="{if strlen($row->begin_month)}{$row->begin_month}{/if}" class="col-xs-5" />
				<span class="some-line">-</span>
				<input type="text" id="end_month" name="end_month" value="{if strlen($row->end_month)}{$row->end_month}{/if}" class="col-xs-5" />
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="gmonth"> 公积金缴费月份 </label>
			<div class="col-sm-2">
				<input type="text" id="begin_gmonth" name="begin_gmonth" @="#end_gmonth" value="{if strlen($row->begin_gmonth)}{$row->begin_gmonth}{/if}" class="col-xs-5" />
				<span class="some-line">-</span>
				<input type="text" id="end_gmonth" name="end_gmonth" value="{if strlen($row->end_gmonth)}{$row->end_gmonth}{/if}" class="col-xs-5" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="social_price"> 社保费用 </label>
			<div class="col-sm-2">
				<input type="text" id="social_price" name="social_price" value="{$row->social_price}" class="col-xs-5" />
				<span class="some-line">元</span>
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="gjj_price"> 公积金费用 </label>
			<div class="col-sm-2">
				<input type="text" id="gjj_price" name="gjj_price" value="{$row->gjj_price}" class="col-xs-5" />
				<span class="some-line">元</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="service_price"> 社保服务费 </label>
			<div class="col-sm-2">
				<input type="text" id="service_price" name="service_price" value="{$row->service_price}" class="col-xs-5" />
				<span class="some-line">元</span>
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="gjj_service_price"> 公积金服务费 </label>
			<div class="col-sm-2">
				<input type="text" id="gjj_service_price" name="gjj_service_price" value="{$row->gjj_service_price}" class="col-xs-5" />
				<span class="some-line">元</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="total_price"> 总缴费费用 </label>
			<div class="col-sm-2">
				<input type="text" id="total_price" name="total_price" value="{$row->total_price}" class="col-xs-5" />
				<span class="some-line">元</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="remark1"> 备注1 </label>
			<div class="col-sm-2">
				<textarea id="remark1" name="remark1" class="col-xs-12">{$row->remark1}</textarea>
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="remark2"> 备注2 </label>
			<div class="col-sm-2">
				<textarea id="remark2" name="remark2" class="col-xs-12">{$row->remark2}</textarea>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="status"> 社保增员状态 </label>
			<div class="col-sm-2">
				<select id="status" name="status">
				{foreach from=$status key=k item=g}
				<option value="{$k}" {if strval($k)==strval($row->status)}selected{/if}>{$g}</option>
				{/foreach}
				</select>
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="status"> 社保扣费状态 </label>
			<div class="col-sm-2">
				<select id="kstatus" name="kstatus">
				{foreach from=$kstatus key=k item=g}
				<option value="{$k}" {if strval($k)==strval($row->kstatus)}selected{/if}>{$g}</option>
				{/foreach}
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="status"> 公积金增员状态 </label>
			<div class="col-sm-2">
				<select id="gstatus" name="gstatus">
				{foreach from=$gstatus key=k item=g}
				<option value="{$k}" {if ($row->id>0 && strval($k)==strval($row->gstatus)) || ($row->id==0 && intval($k)==5)}selected{/if}>{$g}</option>
				{/foreach}
				</select>
			</div>
			<label class="col-sm-2 control-label no-padding-right" for="status"> 公积金扣费状态 </label>
			<div class="col-sm-2">
				<select id="gkstatus" name="gkstatus">
				{foreach from=$gkstatus key=k item=g}
				<option value="{$k}" {if strval($k)==strval($row->gkstatus)}selected{/if}>{$g}</option>
				{/foreach}
				</select>
			</div>
		</div>

		<div class="clearfix form-actions">
			<div class="col-md-offset-3 col-md-9">
				<button class="btn btn-info" type="submit">
					<i class="ace-icon fa fa-check bigger-110"></i>
					提交
				</button>

				&nbsp; &nbsp; &nbsp;
				<button class="btn" type="button" onclick="javascript:history.go(-1);">
					<i class="ace-icon fa fa-undo bigger-110"></i>
					返回
				</button>
			</div>
		</div>
	</form>
</div>
</div>

{include file="footer.html"}
<script>
var casy_id = Number('{$row->casy_id}');
function check(){
	if(!$('#city_id').selected().val().length){
		$.overloadError('请选择城市');
		return false;
	}
	if(!$('#casy_id').selected().val().length){
		$.overloadError('请选择社保档次');
		return false;
	}
	if(!$('#member_type').val().length){
		$.overloadError('请选择付款渠道');
		return false;
	}
	if(!$('#member_name').val().length){
		$.overloadError('请填写账号');
		return false;
	}
	if(!$('#begin_time').val().length){
		$.overloadError('请选择首次缴费日期');
		return false;
	}
	if(!$('#real_name').val().length){
		$.overloadError('请填写姓名');
		return false;
	}
	// if(!$('#idcard').coo('idcardstrict')){
	// 	$.overloadError($('#idcard').data('coo.error'));
	// 	return false;
	// }
	if($('#idcard').val().length!=18){
		$.overloadError('身份证必须为18位');
		return false;
	}
	if(!$('#begin_month').val().length || !$('#end_month').val().length){
		$.overloadError('请选择缴费月份');
		return false;
	}
}
$(function(){
	$('#begin_time').datepicker({
		readonly: false
	});
	$('#begin_month').datepicker({
		readonly: false,
		just:'month',
		format:'yyyy-m'
	});
	$('#end_month').datepicker({
		readonly: false,
		just:'month',
		format:'yyyy-m',
		callback:function(){
			$('#social_price').keyup();
		}
	});
	$('#begin_gmonth').datepicker({
		readonly: false,
		just:'month',
		format:'yyyy-m'
	});
	$('#end_gmonth').datepicker({
		readonly: false,
		just:'month',
		format:'yyyy-m'
	});
	$('#social_price, #gjj_price, #service_price, #gjj_price, #gjj_service_price').keyup(function(){
		if(!$('#begin_month').val().length || !$('#end_month').val().length)return;
		var social_price = Number($('#social_price').val()),
			service_price = Number($('#service_price').val()),
			gjj_price = Number($('#gjj_price').val()),
			gjj_service_price = Number($('#gjj_service_price').val());
			// total_price = social_price+service_price+gjj_price+gjj_service_price;
		var month = $('#begin_month').val().dateDiffNum('m', $('#end_month').val())+1, gmonth = 0;
		if($('#begin_gmonth').val().length && $('#end_gmonth').val().length){
			gmonth = $('#begin_gmonth').val().dateDiffNum('m', $('#end_gmonth').val())+1;
		}
		$('#total_price').val((social_price+service_price)*month+(gjj_price+gjj_service_price)*gmonth);
	});
	$('#city_id').change(function(){
		var val = $(this).selected().val(), html = '<option value="">请选择社保档次</option>', casy = $('#casy_id').html(html);
		if(!val.length)return;
		idx=0;
		idx_id=0;
		$.getJSON('api.php?app=collect&act=get_casy&city_id='+val, function(json){
			$.each(json.data, function(){
				html += '<option value="'+this.id+'">'+this.name+'</option>';
				idx_id=this.id;
				idx++;
			});
			casy.html(html);
			if(casy_id>0){
				casy.selected(''+casy_id);
			} else {
				if (idx==1 && idx_id>0) casy.selected(''+idx_id);
			}
		});
	}).change();
});
</script>

